home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / B-C / C++ FAQ Reference 1.0.sit / C++ FAQ Reference 1.0.rsrc / TEXT_628.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  375 b   |  10 lines

  1. Provide a friend operator<<:
  2.     class X {
  3.       int i;    //just for illustration
  4.     public:
  5.       friend ostream& operator<<(ostream& o, const X& x) { return o << x.i; }
  6.       //...
  7.     };
  8.  
  9. We use a friend rather than a member since the 'X' parameter is 2nd, not 1st. Input is similar, but the signature is:
  10.     istream& operator>> (istream& i, X& x);  //not 'const X& x' !!